package com.jstyle.jclifexd.utils;

import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;

public class SharedPreferenceUtils {
    public static final String KEY_BPCalibration_High = "KEY_BPCalibration_High_02";
    public static final String KEY_BPCalibration_Low = "KEY_BPCalibration_Low_02";

    public static final String KEY_REMIND_PSD = "REMIND_PSD_02";
    public static final String KEY_fwVersion = "KEY_fwVersion_02";
    public static final String KEY_account_type = "KEY_account_type_02";
    public static final String KEY_countryCode = "KEY_countryCode_02";
    public static final String KEY_TimeZone = "KEY_TimeZone_02";
    public static final String KEY_DFU_ADDRESS = "KEY_DFU_ADDRESS_02";
    public static final String KEY_Exercise_Mode = "KEY_Exercise_Mode_02";
    public static final String KEY_Enable_ActivityClock = "KEY_Enable_ActivityClock_02";
    public static final String KEY_UNIT_WEIGHT = "KEY_UNIT_WEIGHT_02";
    public static final String KEY_UNIT_HEIGHT = "KEY_UNIT_HEIGHT_02";
    public static final String KEY_En_WEIGHT = "KEY_En_WEIGHT_02";

    public static final String KEY_RES_FILEPATH = "KEY_RES_FILEPATH_02";
    public static final String KEY_Is_First = "KEY_Is_First_02";
    public static final String KEY_Is_First_showAgreement = "KEY_Is_First_Agreement_02";//是否开启隐私
    public static final String KEY_From_Login = "KEY_From_Login_02";
    public static final String KEY_PHONE = "PHONE_02";
    public static final String KEY_UID = "uid_02";
    public static final String KEY_PSD = "PSD_02";
    public static final String KEY_ADDRESS = "ADDRESS_02";
    public static final String KEY_Language = "Language_02";
    public static final String KEY_LOGIN = "lOGIN_02";
    public static final String KEY_NICKNAME = "nickname_02";
    private static final String spName = "jstyle_sleep_02";
    public static final String KEY_AUTH_USERID = "KEY_AUTH_USERID_02";
    public static final String KEY_highHeart = "highHeart_02";
    public static final String KEY_highBrEATH = "highBrEATH_02";
    public static final String KEY_lowHeart = "lowHeart_02";
    public static final String KEY_lowBreath = "lowBreath_02";
    public static final String KEY_deviceName = "deviceName_02";
    public static final String KEY_PLAN_ON = "PLAN_ON_02";
    public static final String KEY_PLAN_first = "PLAN_first_02";
    public static final String KEY_Sleep_goal = "KEY_Sleep_goal_02";
    public static final String KEY_Step_goal = "KEY_Step_goal_02";
    public static final String KEY_deviceType = "KEY_deviceType_02";
    private static SharedPreferences sp;
    public static final String DefaultCountryCode = "0086-";
    public static void init(Context context) {
        sp = context.getSharedPreferences(spName, Activity.MODE_PRIVATE);
    }

    public static SharedPreferences getSharedPreferences() {
        return sp;
    }

    public static void setSpBoolean(String name, boolean bool) {

        getSharedPreferences().edit().putBoolean(name, bool).commit();
    }

    public static boolean getSpBoolean(String name) {
        return getSharedPreferences().getBoolean(name, false);
    }

    public static boolean getBoolean(String name, boolean defaultValue) {
        return getSharedPreferences().getBoolean(name, defaultValue);
    }

    public static void setSpString(String name, String value) {
        getSharedPreferences().edit().putString(name, value).commit();
    }

    public static String getSpString(String name) {
        return getString(name, null);
    }

    public static String getString(String name, String defaultValue) {
        return getSharedPreferences().getString(name, defaultValue);
    }

    public static void setSpInteger(String name, int value) {
        getSharedPreferences().edit().putInt(name, value).commit();
    }

    public static int getInteger(String name, int defaultValue) {
        return getSharedPreferences().getInt(name, defaultValue);
    }

    public static int getSpInteger(String name) {
        return getInteger(name, -1);
    }

    public static void setSpFloat(String name, float value) {
        getSharedPreferences().edit().putFloat(name, value).commit();
    }

    public static float getSpFloat(String name) {
        return getFloat(name, 0.0f);
    }

    public static float getFloat(String name, float defaultValue) {
        return getSharedPreferences().getFloat(name, defaultValue);
    }
}
